﻿namespace ZL.Web.Utility.Config
{
    public class ZLConfig
    {
        public static bool IsnotifyDecrypt = false;
        private static TenPayV3Model _tenPayV3;


        /// <summary>
        /// 微信支付相关参数
        /// </summary>
        public static string TenPayV3Model
        {
            get { return GloabConfigLoader.GetConfigTenPayV3ModelValue(); }

        }

        public static TenPayV3Model TenPayV3
        {
            get
            {
                if (_tenPayV3 == null || IsnotifyDecrypt)
                {
                    _tenPayV3 = ConfContent.DecryptFromBase64Format(TenPayV3Model, "trfv3_olweixinpay");
                    IsnotifyDecrypt = false;
                }
                return _tenPayV3;
            }
            set { _tenPayV3 = value; }
        }

        /// <summary>
        /// 微信消息加密key
        /// </summary>
        public static string WeixinEncodingAESKey
        {
            get { return GloabConfigLoader.GetConfigValue("WeixinEncodingAESKey"); }
        }

        /// <summary>
        /// 微信消息
        /// </summary>
        public static string WeixinToken
        {
            get { return GloabConfigLoader.GetConfigValue("WeixinToken"); }
        }

        /// <summary>
        /// 微信会员卡cardid
        /// </summary>
        public static string WeixinCardid
        {
            get { return GloabConfigLoader.GetConfigValue("WeixinCardid"); }
        }

        /// <summary>
        /// 公司信息
        /// </summary>
        public static string Couserab
        {
            get { return GloabConfigLoader.GetConfigValue("Couserab"); }
        }

        /// <summary>
        /// 领卡链接信息
        /// </summary>
        public static string RegesiterUrl
        {
            get { return GloabConfigLoader.GetConfigValue("RegesiterUrl"); }
        }

        /// <summary>
        /// Redis连接字符串
        /// </summary>
        public static string SERedis
        {
            get { return GloabConfigLoader.GetConfigValue("SERedis", false); }
        }

        public static bool HasRedis
        {
            get { return SERedis != null; }
        }

        public static string ExceptionLog
        {
            get { return GloabConfigLoader.GetConfigValue("ExceptionLog", false); }
        }

        public static ExceptionLogType ExceptionType
        {
            get
            {
                if (ExceptionLog == "1")
                {
                    return ExceptionLogType.MongoDB;
                }
                else if (ExceptionLog == "2")
                {
                    return ExceptionLogType.ExceptionLess;
                }
                else
                {
                    return ExceptionLogType.None;
                }
            }
        }

        /// <summary>
        /// 微信Token服务器
        /// </summary>
        public static string WeiXinTokenserver
        {
            get { return GloabConfigLoader.GetConfigValue("WeiXinTokenserver"); }
        }

        /// <summary>
        /// 服务请求计数统计标志位
        /// </summary>
        public static string VisitorCounter
        {
            get { return GloabConfigLoader.GetConfigValue("VisitorCounter"); }
        }

        /// <summary>
        ///  Mongodb地址
        /// </summary>
        public static string Mongodbserver
        {
            get { return GloabConfigLoader.GetConfigValue("Mongodbserver"); }
        }

        /// <summary>
        /// 序列号生成的特征值
        /// </summary>
        public static string WorkerId
        {
            get { return GloabConfigLoader.GetConfigValue("WorkerId"); }
        }

        /// <summary>
        /// 是否需要把异常记录下来
        /// </summary>
        public static string ExceptionEnabled
        {
            get { return GloabConfigLoader.GetConfigValue("ExceptionEnabled"); }
        }

        /// <summary>
        /// 输出SQL的调试模式
        /// </summary>
        private static string RunMode
        {
            get { return GloabConfigLoader.GetConfigValue("RunMode"); }
        }

        public static bool IsDevModel
        {
            get { return RunMode.ToLower() == "dev"; }
        }

        /// <summary>
        /// RabbitMQ连接地址
        /// </summary>
        public static string RabbitConnection
        {
            get { return GloabConfigLoader.GetConfigValue("RabbitConnection"); }
        }

        /// <summary>
        /// Sno服务地址
        /// </summary>
        public static string SnoServer
        {
            get { return GloabConfigLoader.GetConfigValue("SnoServer"); }
        }

        /// <summary>
        /// TokenKey
        /// </summary>
        public static string TokenKey
        {
            get { return GloabConfigLoader.GetConfigValue("TokenKey", false); }
        }

        public static string appid_j
        {
            get { return GloabConfigLoader.GetConfigValue("appid_j", false); }
        }

        public static string AppSecret
        {
            get { return GloabConfigLoader.GetConfigValue("AppSecret", false); }
        }

        public static string Coupon_stock_id
        {
            get
            {
                //return "2552402";
                return GloabConfigLoader.GetConfigValue("Coupon_stock_id", false);
            }
        }
        public static string Certname
        {
            get
            {
                //return "apiclient_cert.p12";
                return GloabConfigLoader.GetConfigValue("Certname", false);
            }
        }

        public static string AmountTemplateId
        {
            get
            {
                return GloabConfigLoader.GetConfigValue("AmountTemplateId", false);
            }
        }

        public static string CouponTemplateId
        {
            get
            {
                return GloabConfigLoader.GetConfigValue("CouponTemplateId", false);
            }
        }

        public static string WeixkYueBaolFangsh
        {
            get
            {
                return GloabConfigLoader.GetConfigValue("WeixkYueBaolFangsh", false);
            }
        }

        public static bool IsSupportBalance
        {
            get
            {
                if (WeixkYueBaolFangsh == "1") return true;
                return false;
            }
        }

        public static string Goods_tag
        {
            get
            {
                return GloabConfigLoader.GetConfigValue("Goods_tag", false);
            }
        }
    }

    public enum ExceptionLogType
    {
        None,
        MongoDB,
        ExceptionLess
    }

}
